package com.tedu.day1_25.p1;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory f=new ConnectionFactory();
        f.setHost("192.168.64.140");
        f.setPort(5672);
        f.setUsername("admin");
        f.setPassword("admin");

        Channel c=f.newConnection().createChannel();
//        声明交换机方式
        /*@Parma
        * 1.交换机名称
        * 2.交换方式*/
        c.exchangeDeclare("logs", BuiltinExchangeType.FANOUT);

        while (true){
            System.out.println("enter:");
            String s=new Scanner(System.in).nextLine();
            /*
             * @Param
             * 1.队列
             * 2.ack 模式
             * 3.处理消息回调
             * 取消处理消息回调*/
            c.basicPublish("logs", "", null, s.getBytes());

        }


    }
}
